package com.example.springbootcaffeinedemo.controller;

import com.example.springbootcaffeinedemo.entity.Account1;
import com.example.springbootcaffeinedemo.service.Account1Service;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by IntelliJ IDEA2022.3.2
 * @Author: Tenghw
 * @Date: 2023/04/18  18:26
 * @Description:
 */
@RestController
public class Account1Controller {
    @Resource
    private Account1Service account1Service;

    @GetMapping(value = "/queryById2")
    public Account1 queryById2(Integer id) {
        Account1 account1 = account1Service.queryById2(id);
        return account1;
    }


    @GetMapping(value = "/saveAccount1")
    public String saveAccount1(Integer id) {
        Account1 account1 = new Account1();
        account1.setId(id);
        account1.setName("阿飞");
        account1.setPassword("123");
        account1.setIntegral(0);
        account1.setRemarks(StringUtils.EMPTY);
        account1Service.saveAccount1(account1);
        return "success";
    }

    @GetMapping(value = "/delUser")
    public String delUser(Integer id) {
        account1Service.delUser(id);
        return "delete-cache-success";
    }

    @GetMapping(value = "/queryById1")
    public Account1 queryById1(Integer id) {
        Account1 account1 = account1Service.queryById1(id);
        return account1;
    }

    @GetMapping(value = "/insertAccount1")
    public boolean insertAccount1(Integer id) {
        return account1Service.insertAccount1(id);
    }

}
